package com.yuntsg.nnsfcp.controller.back;

import com.yuntsg.nnsfcp.common.beans.ResultBean;
import com.yuntsg.nnsfcp.service.CommonService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/sys")
//@Api(tags = "首页数据")
@Slf4j
public class HomeController {

    @Resource
    HttpSession session;
    @Resource
    private CommonService commonService;

    @GetMapping("/home")
    //@ApiOperation(value = "获取首页数据接口")
    public ResultBean<Object> getHomeInfo() {
        /**
         * 通过HttpSession拿userId
         */
        if (session.getAttribute("uid") == null) {
            return new ResultBean<>();
        }
        String userId = session.getAttribute("uid").toString();
        log.info("用户id：{}", userId);
        return new ResultBean<>(commonService.getHomeInfo(Integer.valueOf(userId)));
    }


}
